package queue;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Arrays;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Person implements Comparable<Person> {
    private String name;
    private int age;
    private Double score;

    public Person(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(Person o) {
        return this.age - o.age;//升序;
//        return o.age-this.age;//降序
    }

    public static void main(String[] args) throws Exception {
        Person student1 = new Person("小明", 12);
        Person student2 = new Person("小红", 10);
        Person student3 = new Person("小刘", 15);
        Person[] student = {student1, student2, student3};
        Arrays.sort(student);
        Arrays.stream(student).forEach(System.out::print);

    }
}